import { reactive, ref } from "vue";
interface RegisterParm {
    username: string,
    password: string,
    password2: string,
    realName: string,
    phone: string,
}

// 这里写验证规则
export default function useBaseRegister() {
    //表单的ref属性
    const registerFormRef = ref(null);

    //表单绑定的数据
    const registerModel = reactive<RegisterParm>({
        username: '',
        password: '',
        password2: '',
        realName: '',
        phone: '',
    })

    //表单验证规则
    const rules = reactive({
        username: [{
            required: true,
            trigger: 'change',
            message: '请设置新账户',
            minlength:6,
            MaxLength:18
        }],
        password: [{
            required: true,
            trigger: 'change',
            message: '请设置登录密码',
            minlength:6,
            MaxLength:18
        }],
        password2: [{
            required: true,
            trigger: 'change',
            message: '请再次填写密码'
        }]
    })
    return {
        registerModel,
        rules,
        registerFormRef
    }
}